import QtQuick 2.0
import QtQuick.Controls 1.2
import "./components/"
import "../javascript/Utils.js" as UtilsJS


import Utils 1.0

Item {
    property string titulo: "Mapa"
    property var subTitulo: null
    property bool showMenuButton: false
    property var lat
    property var lon

    id: mapaRoot
    width: parent.width
    height: parent.height

    property Rectangle toolBarMenu: Rectangle {
        width: UtilsJS.dp2px(150)
        height: menuItems.height
        color: "#f3f3f3"

        Column {
            id: menuItems
            width: parent.width

            Button {
                text: "Info"
                style: applicationWindow.botoesDrawer
                width: parent.width
                height: UtilsJS.dp2px(48)
                property string icon: ""
                onClicked: {
                    applicationWindow.hideToolBarMenu();
                    applicationWindow.showPath();
                }
            }
        }
    }

    MapComponent {
        id: map
        width: parent.width
        height: parent.height
        onMarkerClicked: applicationWindow.exibeProdutos(id,label)
    }

    function setMapCenter(latitude, longitude) {
        lat = latitude;
        lon = longitude;
        map.setCenter(lat, lon);
    }

    function doUpdate() {
        map.deleteMarkers();
        map.addMarkers(fornecedoresController.loadDadosFornecedores());
        setMapCenter(lat,lon);
    }

    function back() {
        return true;
    }
}

